layui.use(['form','layer','jquery'],function(){
	localStorage.login_font_name="";
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer
        $ = layui.jquery;

    $(".loginBody .seraph").click(function(){
        layer.msg("这只是做个样式，至于功能，你见过哪个后台能这样登录的？还是老老实实的找管理员去注册吧",{
            time:5000
        });
    })

    //登录按钮
    form.on("submit(login)",function(data){
        //$(this).text("登录中...").attr("disabled","disabled").addClass("layui-disabled");
        var action 	= data.form.action;//表单提交URL地址
        setTimeout(function(){
        	$.post(action,data.field,function(obj){
	        	//console.log(obj);
	            //根据返回结果作出相应处理
				
				console.log(obj);
	            if (obj.code == 200) {
					
	            	layer.msg(obj.msg);
					//document.cookie = "username="+obj.login_name+"; expires=Sun, 31 Dec 2017 12:00:00 UTC";
					localStorage.login_font_name = obj.login_name;
					localStorage.login_font_role = obj.login_role;
					localStorage.login_font_yongjin = obj.data['0']['font_money'];
					console.log(localStorage.login_font_yongjin);
					if (obj.login_role==2) {
						setTimeout(function(){
		            		window.location.href = "http://127.0.0.1:89/font/index.html";
		            	},2000);
					} else{
						setTimeout(function(){
		            		window.location.href = "http://127.0.0.1:89/font/index.html";
		            	},2000);
					}
	            	
	            	
	            } else{
	            	layer.msg(obj.msg);
	            }
	        });
        },1000);
        return false;
    })

    //表单输入效果
    $(".loginBody .input-item").click(function(e){
        e.stopPropagation();
        $(this).addClass("layui-input-focus").find(".layui-input").focus();
    })
    $(".loginBody .layui-form-item .layui-input").focus(function(){
        $(this).parent().addClass("layui-input-focus");
    })
    $(".loginBody .layui-form-item .layui-input").blur(function(){
        $(this).parent().removeClass("layui-input-focus");
        if($(this).val() != ''){
            $(this).parent().addClass("layui-input-active");
        }else{
            $(this).parent().removeClass("layui-input-active");
        }
    })
})
